package com.karson.model;

import javax.persistence.*;
import java.sql.Timestamp;
import java.util.Objects;

/**
 * @author Karson
 * @created on 2017/12/13
 */
@Entity
@Table(name = "mmall_user", schema = "happymall", catalog = "")
public class MmallUser {
    private int id;
    private String username;
    private String password;
    private String email;
    private String phone;
    private String question;
    private String answer;
    private int role;
    private Timestamp createTime;
    private Timestamp updateTime;

    public MmallUser(int id, String username, String password, String email, String phone, String question, String answer, int role, Timestamp createTime, Timestamp updateTime) {
        this.id = id;
        this.username = username;
        this.password = password;
        this.email = email;
        this.phone = phone;
        this.question = question;
        this.answer = answer;
        this.role = role;
        this.createTime = createTime;
        this.updateTime = updateTime;
    }

    public MmallUser() {
    }

    @Id
    @Column(name = "id", nullable = false)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "username", nullable = false, length = 50)
    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Basic
    @Column(name = "password", nullable = false, length = 50)
    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Basic
    @Column(name = "email", nullable = true, length = 50)
    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    @Basic
    @Column(name = "phone", nullable = true, length = 20)
    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    @Basic
    @Column(name = "question", nullable = true, length = 100)
    public String getQuestion() {
        return question;
    }

    public void setQuestion(String question) {
        this.question = question;
    }

    @Basic
    @Column(name = "answer", nullable = true, length = 100)
    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

    @Basic
    @Column(name = "role", nullable = false)
    public int getRole() {
        return role;
    }

    public void setRole(int role) {
        this.role = role;
    }

    @Basic
    @Column(name = "create_time", nullable = false)
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time", nullable = false)
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        MmallUser mmallUser = (MmallUser) o;
        return id == mmallUser.id &&
                role == mmallUser.role &&
                Objects.equals(username, mmallUser.username) &&
                Objects.equals(password, mmallUser.password) &&
                Objects.equals(email, mmallUser.email) &&
                Objects.equals(phone, mmallUser.phone) &&
                Objects.equals(question, mmallUser.question) &&
                Objects.equals(answer, mmallUser.answer) &&
                Objects.equals(createTime, mmallUser.createTime) &&
                Objects.equals(updateTime, mmallUser.updateTime);
    }

    @Override
    public int hashCode() {

        return Objects.hash(id, username, password, email, phone, question, answer, role, createTime, updateTime);
    }
}
